<?php

namespace app\common\model\trait;

trait ConstIsPass
{
    /**
     * @var int 待审核
     */
    static int $IS_PASS_WAIT = 0;
    /**
     * @var int 审核通过
     */
    static int $IS_PASS_PASSED = 1;
    /**
     * @var int 审核不通过
     */
    static int $IS_PASS_NOT_PASSED = -1;

    /**
     * 获取审核 列表
     * @return array[]
     */
    public static function getIsPassList(): array
    {
        return [
            ["value" => 0, "name" => "待审核"],
            ["value" => 1, "name" => "通过"],
            ["value" => -1, "name" => "不通过"],
        ];
    }

    /**
     * 获取审核文本
     * @param $value
     * @param $data
     * @return string
     */
    public function getIsPassTextAttr($value, $data): string
    {
        $text = "";
        $isPass = getValueFromArray("is_pass", $data);
        if ($isPass == self::$IS_PASS_WAIT) {
            $text = "待审核";
        }
        if ($isPass == self::$IS_PASS_PASSED) {
            $text = "通过";
        }
        if ($isPass == self::$IS_PASS_NOT_PASSED) {
            $text = "不通过";
        }
        return $text;
    }
}